﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using XRpgLibrary;
using XRpgLibrary.TileEngine;
using EyesOfTheDragon.Components;
using EyesOfTheDragon.Events;
using XRpgLibrary.Events;
namespace Anthem.Components
{
    public class Monster: IUpdate, IPauseable
    {
        #region Field Region
        Camera camera;
        Game1 gameRef;
        bool enabled = false;
        #endregion
        
        #region Property Region
        public bool Enabled
        {
            get { return enabled; }
            set { enabled = value; }
        }
        public void removeMonster(MonsterSprite ms)
        {
            Monsters.Remove(ms);
        }
        public static Monster Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new Monster();
                return _instance;
            }
        }
        public void Clear()
        {
            foreach (MonsterSprite ms in Monsters)
            {
                DestroyList.Instance.add(ms);
            }
            Monsters.Clear();
        }
        private static Monster _instance;
        public List<MonsterSprite> Monsters = new List<MonsterSprite>();
        public Camera Camera
        {
            get { return camera; }
            set { camera = value; }
        }
        #endregion
        #region Constructor Region
        protected void Player_Killed()
        {
            Clear();
        }
        public Monster()
        {
            ///empty constructor
           
        }
        public Monster(Game game)
        {
            gameRef = (Game1)game;
            camera = new Camera(gameRef.ScreenRectangle);
            _instance = this;
            EventRouter.Instance.add(Player.PlayerKilled, Player_Killed);
        }
        #endregion
        #region Method Region
        public void Update(GameTime gameTime)
        {
         //   camera.Update(gameTime);
            foreach (MonsterSprite ms in Monsters)
            {
                ms.Update(gameTime);
            }
        }
        /*
         * Implementing a draw method would be unwise because monsters will not all be on the same layer
         * Instead, each monster should implement draw individually..
         * 
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            foreach (MonsterSprite ms in Monsters)
            {
                ms.Draw(gameTime, spriteBatch);
            }
        }*/
        #endregion
    }
}